<template>
	<view class="box" :style="theme">
		<!-- 项目类型 -->
		<scroll-view scroll-x v-if="table&&table.length>0" class="box_tabls">
			<view class="box_tabls_left">
				<view class="box_tabls_left_item" :class="activeIndex == index ? 'active' : ''"
					v-for="(item, index) in table" :key="index" @click="clickTbas(index)">{{item.projectName}}</view>

			</view>
			<!-- 			<view v-if="isOpen" class="box_tabls_right">
				<u-icon :name="isOpen?'arrow-down':'arrow-up'" @click="clickIcon" />
			</view> -->
		</scroll-view>
		<view style="height: 30rpx;"></view>
		<TcList :list="list" />
		<u-loadmore v-if="end && list.length >= 10" :status="status" line />
		<view v-if="list.length === 0" class="no-order">
			<image :src="imgHost+'/default_nodata.png'"></image>
			<view>暂无数据</view>
		</view>
	</view>
</template>
<script>
	import TcList from "@/components/tcList.vue";
	export default {
		components: {
			TcList
		},
		data() {
			return {
				table: [],
				status: 'nomore',
				firstQueryTime: '',
				list: [],
				activeIndex: 0,
				orderId: '',
				page: 1,
				rows: 10,
				noClick: true,
				end: false,
				isOpen: true
			}
		},
		async onLoad(ops) {
			await this.$onLaunched;
			this.orderId = ops.orderId || ''
			this.firstQueryTime = this.$app.firstQueryTime()
			this.getProject()
			const scene = decodeURIComponent(ops.scene)
			if (scene && scene != 'undefined') {
				uni.setStorage({
					key: 'shareMemberId',
					data: scene
				});
				this.addShareMemberRelevance(scene)
			}
		},
		onShow() {
			if (this.userInfo && uni.getStorageSync('shareMemberId') && uni.getStorageSync('shareMemberId') !=
				'undefined') {
				this.addShareMemberRelevance(uni.getStorageSync('shareMemberId'))
			}
		},
		methods: {
			jump(url, params, a) {
				this.$app.jump(url, params, a);
			},
			jump2(url, params, a) {
				this.$app.jump2(url, params, a);
			},
			addShareMemberRelevance(shareMemberId) {
				this.$app.ajax({
					data: {
						param: {
							shareMemberId
						}
					},
					api: this.$api.addShareMemberRelevance()
				}).then((res) => {
					if (res.errorCode === '000000') {
						uni.removeStorageSync('shareMemberId');
					}
				})
			},
			// 点击箭头
			clickIcon() {
				this.isOpen = !this.isOpen
			},
			clickTbas(index) {
				this.activeIndex = index
				this.list = [];
				this.page = 1;
				this.end = false;
				this.getList()
			},
			getProject() {
				this.$app.ajax({
					data: {
						param: {
							venueId: this.venueId,
							projectName: '',
							status: '1',
						}
					},
					api: this.$api.getProject()
				}).then((res) => {
					if (res.errorCode === '000000') {
						this.table = [{
							projectName: '全部',
							id: ''
						}, ...res.recordList]
						this.getList()
					}
				}).catch(() => {})
			},
			getList() {
				this.$app.ajax({
					api: this.$api.mealsOnlineList(),
					data: {
						pagination: {
							page: this.page,
							firstQueryTime: this.firstQueryTime,
							rows: this.rows
						},
						param: {
							venueId: this.venueId,
							orderId: this.orderId,
							projectId: this.table[this.activeIndex].id
						}
					}
				}).then((res) => {
					if (res.errorCode === '000000') {
						if (!res.recordList || res.recordList.length < this.rows) {
							this.end = true
						}
						if (res.recordList) {
							this.list = this.list.concat(res.recordList)
						}
					}
				}).catch(() => {})
			},
			reachBottom() {
				if (!this.end) {
					this.page += 1;
					this.getList();
				}
			},
			// 触底加载更多数据
			onReachBottom(e) {
				this.reachBottom()
			}

		}

	}
</script>
<style lang="scss" scoped>
	.box_tabls {
		display: flex;
		/* align-items: center; */
		justify-content: space-between;
		padding: 30rpx;
		background: #ffffff;
		position: sticky;
		top: 0;
		left: 0;
		right: 0;
		overflow: hidden;
		z-index: 999;
		.box_tabls_left {
			white-space: nowrap;
			display: flex;

			.box_tabls_left_item {
				padding: 0 46rpx;
				line-height: 70rpx;
				border-radius: 35rpx;
				font-size: 24rpx;
				font-weight: 400;
				color: #111111;
				background: $bjColor;
				margin-right: 16rpx;

				&:last-of-type {
					margin-right: 0;
				}

				&.active {
					color: #ffffff;
					background: $color;
				}
			}
		}
	}

	.box_piao {
		padding: 24rpx 30rpx;
		box-sizing: border-box;
	}

	.box_piao_item {
		padding: 30rpx;
		// height: 180rpx;
		box-sizing: border-box;
		background: #FFFFFF;
		border-radius: 16rpx;
		display: flex;
		align-items: center;
		justify-content: space-between;
		margin-bottom: 24rpx;
	}

	.box_piao_item_left image {
		width: 120rpx;
		height: 120rpx;
		flex-shrink: 0;
	}

	.box_piao_item_left_t {
		display: flex;
		flex-direction: column;
		justify-content: space-between;
		margin-left: 30rpx;

		.name {
			width: 348rpx;
			font-size: 30rpx;
			font-weight: 500;
			color: #222222;
			overflow: hidden;
			text-overflow: ellipsis;
			white-space: nowrap;
		}

		.text {
			font-size: 24rpx;
			font-weight: 400;
			color: #999999;
		}

		.date_wrap {
			display: flex;
			flex: 1;
			font-size: 24rpx;
			font-weight: 400;
			color: #222222;

			.key {
				width: 120rpx;
			}

			.value {
				flex: 1;
			}
		}
	}

	.box_piao_item_left {
		width: 80%;
		display: flex;
		overflow: hidden;
	}

	.box_piao_item_right {
		flex: 1;
		text-align: right;
		font-size: 30rpx;
		font-weight: 600;
		color: $color;
	}
</style>